package com.zt.bigdata.helloclient.mongo;

import com.zt.bigdata.document.Customer;
import com.zt.bigdata.repository.CustomerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: zhangtong
 * @Date: 2018/9/13 下午5:55
 */
@Service
public class MongoUserServiceImpl implements MongoUserService {
    @Autowired
    private CustomerRepository repository;


    @Override
    public Page<Customer> findByDelFlag(Boolean delFlag, Pageable pageable) {
        return repository.findByDelFlag(delFlag, pageable);
    }

    @Override
    public Customer findOneByAge(Integer age) {
        return repository.findOneByAge(age);
    }

    @Override
    public Page<Customer> findByName(String name, Pageable pageable) {
        return repository.findByName(name, pageable);
    }

    @Override
    public Page<Customer> findByAge(int age, Pageable pageable) {
        return repository.findByAge(age, pageable);
    }

    @Override
    public List<Customer> findAllByAddress(String address) {
        return repository.findAllByAddress(address);
    }

    @Override
    public Page<Customer> findByAgeGreaterThan(int age, Pageable pageable) {
        return repository.findByAgeGreaterThan(age, pageable);
    }

    @Override
    public Page<Customer> findByNameNotNull(Pageable pageable) {
        return repository.findByNameNotNull(pageable);
    }

    @Override
    public Page<Customer> findByNameLike(String name, Pageable pageable) {
        return repository.findByNameLike(name, pageable);
    }

    @Override
    public List<Customer> deleteByName(String name) {
        return repository.deleteByName(name);
    }

    @Override
    public Long deleteCustomerByName(String name) {
        return repository.deleteCustomerByName(name);
    }

    @Override
    public Customer insert(Customer c) {
        return repository.insert(c);
    }

    @Override
    public void deleteAllByDelFlag(Boolean delFlag) {
        repository.deleteAllByDelFlag(delFlag);
    }
}
